﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VideoClassLibrary.Model;
using VideoClassLibrary.BusinessLogicLayer;
using System.Data;

public partial class SchoolNoticeManagement_AddNotice : AdminUserBase
{
    V_announcement announce = new V_announcement();
    AnnouncementModule am = new AnnouncementModule();
    protected void Page_Load(object sender, EventArgs e)
    {
        trc.Visible = false;
        this.radbtnIsPublish.Enabled = false;
        RequiredFieldValidator3.Enabled = false;
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {

        announce.AnnouncementTitle = this.txtAnnouncementTitle.Text.ToString();
        announce.AnnouncementContent = this.txtAnnouncementContent.Text.ToString();
        announce.CreatedTime = DateTime.Now;
        //if (AdminType == 4)
        //{
        //    announce.IsPublished = 0;
        //}
        //else
        //{

        //    announce.IsPublished = Convert.ToInt32(this.radbtnIsPublish.SelectedValue);

        //}
        announce.IsPublished = Convert.ToInt32(this.radbtnIsPublish.SelectedValue);
        announce.SchoolId = this.SchoolID;
        announce.CreaterId = UserID;
        announce.CreaterName = RealName;
        announce.UpdateTime = DateTime.Now;
        int resurt = am.AddAnnouncement(announce);
        if (resurt != 0)
        {

            PageHelper.AlterMsg("添加成功！");
            Response.Redirect("SearchNoticeList.aspx");
        }
        else
        {

            PageHelper.AlterMsg("添加失败，请重写填写！");
        }
    }

    private void ShowNewHtml()
    {
        DataSet ds = new DataSet();
        AdminModule am = new AdminModule();
        string typeva = AdminType.ToString();
        ds = am.GetAdmin(-1, typeva);
        DataRow dr = ds.Tables[0].Rows[0];
        int result = Convert.ToInt32(dr["VA_type"]);
        if (result != 4)
        {
            trc.Visible = true;
            this.radbtnIsPublish .Enabled = true;
            RequiredFieldValidator3.Enabled = true;

        }

    }
}
